const ejs = require('ejs')
const path =  require('path')
const fs =  require('fs')
const compiler = function(template,data){
  const templatePath = path.resolve(__dirname,`../templates/${template}`)
  return new Promise((resolve,reject)=>{
    ejs.renderFile(templatePath,data,(err,res)=>{
      if (err){
        reject(err)
      }else{
        resolve(res)
      }
    })  
  })
}
const writeToFile= function(path,content){
  fs.promises.writeFile(path,content)
}
module.exports={compiler,writeToFile}